{extend name='./content'}

{block name="button"}
<div class="nowrap pull-right" style="margin-top:10px">
    <div class="layui-btn-group">
        <a href="{$self_url}&#38;date_type=" class="layui-btn layui-btn-small {if $Think.get.date_type != ''}layui-btn-primary{else/}layui-btn-normal{/if}">全部</a>
        <a href="{$self_url}&#38;date_type=month" class="layui-btn layui-btn-small {if $Think.get.date_type != 'month'}layui-btn-primary{else/}layui-btn-normal{/if}">本月</a>
        <a href="{$self_url}&#38;date_type=week" class="layui-btn layui-btn-small {if $Think.get.date_type != 'week'}layui-btn-primary{else/}layui-btn-normal{/if}">本周</a>
        <a href="{$self_url}&#38;date_type=day" class="layui-btn layui-btn-small {if $Think.get.date_type != 'day'}layui-btn-primary{else/}layui-btn-normal{/if}">今日</a>
    </div>
</div>
{/block}

{block name="content"}
<style>
    .show_img img{
    position: absolute;
    top: -53px;
    left: 0;
	display:none;
	max-width: 249px;
    z-index: 2;
}
</style>
<!-- 表单搜索 开始 -->
<form class="layui-form form-search" action="__SELF__" onsubmit="return false" method="get" id="srarch-form">
    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">商户账号</label>
        <div class="layui-input-inline">
            <input name="username" value="{$Think.get.username|default=''}" placeholder="请输入商户账号" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">收款类型</label>
        <div class="layui-input-inline">
            <select name="type">
                <option value="">全部</option>
                <option value="1" {if $Think.get.type==1}selected{/if}>支付宝 </option> <option value="2" {if
                    $Think.get.type==2}selected{/if}>微信 </option> <option value="3" {if $Think.get.type==3}selected{/if}>银行
                    </option> </select> </div> </div> <div class="layui-form-item layui-inline">
                    <label class="layui-form-label">审核状态</label>
                    <div class="layui-input-inline">
                        <select name="status">
                            <option value="">全部</option>
                            <option value="0" {if $Think.get.status==='0' }selected{/if}>待审核 </option> <option value="1"
                                {if $Think.get.status==1}selected{/if}>已打款 </option> <option value="2" {if
                                $Think.get.status==2}selected{/if}>驳回 </option> </select> </div> </div> <div class="layui-form-item layui-inline">
                                <label class="layui-form-label">时间范围</label>
                                <div class="layui-input-inline">
                                    <input name="date_range" id="date_range" value="{:urldecode($Think.get.date_range)}"
                                        placeholder="请选择时间范围" class="layui-input">
                                </div>
                    </div>

                    <div class="layui-form-item layui-inline">
                        <button type="submit" class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜
                            索</button>
                    </div>

                    <div class="layui-form-item layui-inline">
                        <a href="javascript:excel()" class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe62d;</i>
                            导出 excel </a>
                    </div>
</form>
<!-- 表单搜索 结束 -->
<div class="layui-card-body">
    <table class="layui-table" lay-even="" lay-skin="line">
        <colgroup>
            <col width="20%">
            <col width="30%">
            <col width="20%">
            <col width="30%">
        </colgroup>
        <thead>
            <tr>
                <th class="text-left">今日结算总金额</th>
                <th class="text-left">结算总金额</th>
                <th class="text-left">结算手续费</th>
                <th class="text-left">实结金额</th>
                <th class="text-left">未结金额</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td class="nowrap">{$stat.todaysum}</td>
                <td class="nowrap">{$stat.totalsum}</td>
                <td class="nowrap">{$stat.totalfee}</td>
                <td class="nowrap">{$stat.totalactual}</td>
                <td class="nowrap">{$stat.totalmoney}</td>
            </tr>

    </table>
    <button id="pay_batch" type="button" class="layui-btn layui-btn-normal layui-btn-small">批量打款</button>

</div>
<div class="" style="margin-bottom:10px;"></div>
<form onsubmit="return false;" data-auto="true" method="post">
    <input type="hidden" value="resort" name="action" />
    <table class="table table-hover">
        <thead>
            <tr>
                <th class='list-table-check-td'>
                    <input data-none-auto="" data-check-target='.list-check-box' type='checkbox' />
                </th>
                <th class='text-center'>单号</th>
                <th class='text-center'>商户账号</th>
                <th class='text-center'>收款类型</th>
				<th class='text-center'>收款账号</th>
                <th class='text-center'>收款姓名</th>				
                <th class='text-center'>提现金额（元）</th>
                <th class='text-center'>手续费</th>
                <th class='text-center'>实际到账（元）</th>
                <th class='text-center'>状态</th>
                <th class='text-center'>申请时间</th>
                <!--th class='text-center'>打款时间</th-->
                <th class='text-center'>操作</th>
            </tr>
        </thead>
        <tbody>
            {foreach $cashed as $v}
            <tr>
                <td class='list-table-check-td'>
                    <input class="list-check-box" value='{$v.bh}' type='checkbox' />
                </td>
                <td class='text-center'>{$v.bh}</td>
                <td class='text-center'>
					<a data-title="商户信息" data-open='{:url("admin/member/info")}?bh={$v.ubh}' href="javascript:void(0)">{:user_info($v.ubh)['name']}</a>
				</td>
				<td class='text-center'>{$v.type}</td>
                <td class='text-center'>{$v.bankid}</td>               
				<td class='text-center'>{$v.truename}</td>
                <td class='text-center'>{$v.money}</td>
                <td class='text-center'>{$v.fee}</td>
                <td class='text-center'>{$v.actual_money}</td>
                <td class='text-center'>
                    {switch name="$v.zt"}
                    {case value="0"}<font color="blue">待处理</font>{/case}
                    {case value="1"}<font color="green">处理成功</font>{/case}
                    {case value="2"}<font color="red">审核不通过</font>{/case}
					{case value="3"}<font color="red">撤销申请</font>{/case}
                    {/switch}
                </td>
                <td class='text-center'>{$v.sj}</td>
                <!--td class='text-center'>{$v.sj}</td-->
                <td class='text-center'>
                    {if $v.zt==0}
                    <button class="layui-btn layui-btn-small" type="button" onclick="do_action('pass', {$v.bh})">打款</button>
                    <!--button class="layui-btn layui-btn-small" type="button" data-modal='{:url("daifu")}?bh={$v.bh}'>代付打款</button-->
                    <button class="layui-btn layui-btn-small" type="button" onclick="do_action('notpass',{$v.bh})">驳回</button>
                    {else}
                    <button class="layui-btn layui-btn-small" type="button" onclick="do_action('del',{$v.bh})">删除</button>
					{/if}
                </td>
            </tr>
            {/foreach}
        </tbody>
    </table>
</form>
{$page}
<script>
    layui.use('form', function () {
        var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
        form.render();
    });
    layui.use('laydate', function () {
        var laydate = layui.laydate;
        //日期范围
        laydate.render({
            elem: '#date_range',
            range: true
        });
    });

    function do_action(action, id) {
        var name = '';
        if (action == 'pass') {
            name = '是否打款';
        } else if (action == 'notpass') {
            name = '是否驳回';
        } else if (action == 'del') {
            name = '是否删除';
        }
        var name
        layer.confirm(name, function (index) {
            $.ajax({
                url: "{:url('detail')}",
                type: 'post',
                data: {
                    bh: id,
                    action: action
                },
                success: function (res) {
                    if (res.code == 1) {
                        window.location.reload();
                        layer.msg(res.msg, {
                            icon: 1,
                            time: 1000
                        });
                    } else {
                        layer.msg(res.msg, {
                            icon: 1,
                            time: 1000
                        });
                    }
                }
            });
        });
    }

    function excel() {
        window.open('/manage/cash/dumpCashs?' + $('#srarch-form').serialize())
    }

    $(function () {
        $(".show_img a").mouseover(function () {

            $(this).parent().find("img").show();
        });

        $(".show_img img").mouseout(function () {
            $(this).hide();

        });
    });
    $('#pay_batch').click(function () {
        var ids = '';
        $('.list-check-box').each(function () {
            var _this = $(this);
            if (_this.is(':checked')) {
                ids = ids + _this.val() + ',';
            }
        });
        layer.confirm('确定要批量打款吗？', function (index) {
            if (ids == '') {
                layer.msg('请选择提现申请！');
                return false;
            }
            $.ajax({
                url: "/manage/cash/pay_batch",
                type: 'post',
                data: {
                    'ids': ids
                },
                success: function (res) {
                    if (res.code == 1) {
                        layer.msg(res.msg, {
                            icon: 1,
                            time: 1000
                        });
                        $.form.reload();
                    } else {
                        layer.msg(res.msg, {
                            icon: 1,
                            time: 1000
                        });
                    }
                }
            });
        });
    });
</script>
{/block}